package com.feditory.category.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.feditory.common.domain.DataHandleStatus;
import com.feditory.util.DateUtils;

@Entity
@Table(name = "SD_CATEGORY")
public class Category implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 7668334290129156560L;

    /** 카테고리아이디 */
    @Id
    @GeneratedValue(generator = "SQ_CATEGORY")
    @SequenceGenerator(name = "SQ_CATEGORY", initialValue = 1, allocationSize = 1, sequenceName = "SQ_CATEGORY")
    @Column(name = "CATEGORY_ID")
    private long categoryId;

    /** 카테고리타입 */
    @Enumerated(EnumType.STRING)
    @Column(name = "CATEGORY_TYPE", length = 20, nullable = false)
    private CategoryType categoryType;

    /** 카테고리채널타입 */
    @Enumerated(EnumType.STRING)
    @Column(name = "CATEGORY_CHANNEL_TYPE", length = 20, nullable = false)
    private CategoryChannelType categoryChannelType;

    /** 카테고리명 */
    @Column(name = "CATEGORY_NAME", length = 100, nullable = false)
    private String categoryName;

    /** 부모카테고리아이디 */
    @Column(name = "PARENT_CATEGORY_ID", nullable = false)
    private long parentCategoryId;

    /** 화면정렬순선 */
    @Column(name = "DISPLAY_ORDER", nullable = false)
    private int displayOrder;

    @Column(name = "LINK", length = 255)
    private String link;

    @Column(name = "IMAGE_PATH", length = 255)
    private String imagePath;

    @Column(name = "LOGIN_USEABLE_YN", nullable = false)
    private boolean loginUseableYn;

    @Embedded
    private DataHandleStatus handleStatus;

    public void disable() {
        if (this.handleStatus == null) return;
        this.handleStatus.setUseYn(false);
        this.handleStatus.setUpdateDateTime(DateUtils.getCurrentBaseDateString());
    }

    public Category() {

    }

    public long getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(long categoryId) {
        this.categoryId = categoryId;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public long getParentCategoryId() {
        return parentCategoryId;
    }

    public void setParentCategoryId(long parentCategoryId) {
        this.parentCategoryId = parentCategoryId;
    }

    public String getLink() {
        return link;
    }

    public void setLink(String link) {
        this.link = link;
    }

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }

    public DataHandleStatus getHandleStatus() {
        return handleStatus;
    }

    public void setHandleStatus(DataHandleStatus handleStatus) {
        this.handleStatus = handleStatus;
    }

    public int getDisplayOrder() {
        return displayOrder;
    }

    public void setDisplayOrder(int displayOrder) {
        this.displayOrder = displayOrder;
    }

    public CategoryType getCategoryType() {
        return categoryType;
    }

    public void setCategoryType(CategoryType categoryType) {
        this.categoryType = categoryType;
    }

    public CategoryChannelType getCategoryChannelType() {
        return categoryChannelType;
    }

    public void setCategoryChannelType(CategoryChannelType categoryChannelType) {
        this.categoryChannelType = categoryChannelType;
    }

    public boolean isLoginUseableYn() {
        return loginUseableYn;
    }

    public void setLoginUseableYn(boolean loginUseableYn) {
        this.loginUseableYn = loginUseableYn;
    }

}
